import 'package:flutter/material.dart';
import 'package:flutter_audit_app/res/colors.dart';

class PastViolationsPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _PassViolationsState();
}

class _PassViolationsState extends State<PastViolationsPage> {
  List<String> list = [
    '挂床住院',
    '重复入院',
    '冒名就医',
  ];

  var _isSelected = [true, false, false];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            height: 28,
            margin: EdgeInsets.only(left: 20, top: 10),
//    child: _buildSwitchRadio(),
            child: ToggleButtons(
              renderBorder: false,
              children: <Widget>[
                _buildToggleButton('挂床住院'),
                _buildToggleButton('重复住院'),
                _buildToggleButton('冒名就医'),
              ],
              isSelected: _isSelected,
              onPressed: (index) => setState(() {
                _isSelected = _isSelected.map((e) => false).toList();
                _isSelected[index] = true;
              }),
              selectedColor: Color(0xff2A97FE),
              disabledBorderColor: Color(0xff2A97FE),
            ),
          ),
          _buildListViewHeader(),
          Expanded(child: _buildListView()),
        ],
      ),
    );
  }

  Widget _buildToggleButton(String text) {
    return Container(
      width: width(160),
      height: height(40),
      child: Text(
        text,
        style: TextStyle(fontSize: 12),
        textAlign: TextAlign.center,
      ),
    );
  }

  Widget _buildListViewHeader() {
    return Container(
      margin: EdgeInsets.only(left: 20, right: 20, top: 10),
      color: Colours.u_bbd4ee,
      height: 30,
      child: Flex(
        direction: Axis.horizontal,
        children: <Widget>[
          // dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '序号',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '姓名',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '数量',
              style: TextStyle(fontSize:12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '社保卡号',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 3,
            child: Text(
              '医疗机构名称',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '结算时间',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '总金额',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '就诊号',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 3,
            child: Text(
              '身份证号',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '居住地',
              style: TextStyle(fontSize: 12),
              textAlign: TextAlign.center,
            ),
          ),
          // dividerVertical(),
        ],
      ),
    );
  }

  Widget _buildListView() {
    return Container(
      margin: EdgeInsets.only(left: 20, right: 20),
      child: ListView.builder(
        padding: EdgeInsets.only(top: 0),
        itemBuilder: (context, index) => _buildListViewItem(index),
        itemCount: 20,
      ),
    );
  }

  Widget _buildListViewItem(int index) {
    return Container(
     /* color: (index % 2 == 0) ? Colors.white : Color(u_ffeff7fb),
      height: 30,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '${index + 1}',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '菜狗',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '111',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '848753691179',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 3,
            child: Text(
              '火宴山',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '平成28年',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '10000',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 1,
            child: Text(
              '3796110',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 3,
            child: Text(
              '421281198612056520',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
          Expanded(
            flex: 2,
            child: Text(
              '米花町三丁目',
              style: TextStyle(fontSize: isLargeScreen ? 12 : 10),
              textAlign: TextAlign.center,
            ),
          ),
          dividerVertical(),
        ],
      ),*/
    );
  }

  String _value = '挂床住院';

  Widget _buildSwitchRadio() {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: list
          .map((e) => Radio(
                value: Text(e),
                groupValue: _value,
                onChanged: (v) {
                  setState(() {
                    _value = v;
                  });
                },
              ))
          .toList(),
    );
  }

  Widget _buildRadioButton() {
    return Radio(value: null, groupValue: null, onChanged: null);
  }
}
